package com.lwy.qiuchao.integration.controller;

import java.util.Arrays;
import java.util.Map;

import com.lwy.common.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.lwy.qiuchao.integration.entity.DurationEntity;
import com.lwy.qiuchao.integration.service.DurationService;
import com.lwy.common.utils.PageUtils;


/**
 * 
 *
 * @author lwy
 * @email ${email}
 * @date 2020-12-01 15:34:10
 */
@RestController
@RequestMapping("integration/duration")
public class DurationController {
    @Autowired
    private DurationService durationService;

    /**
     * 进入球场和离开球场
     *
     * 参数：进入时： mermberId  fieldId  createtime
     *      离开时： mermberId  fieldId  finishtime
     * */
    @RequestMapping("/infield")
    public R test(@RequestParam Map<String, Object> params){
        durationService.infield(params);
        return R.ok();
    }
    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = durationService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{duraId}")
    public R info(@PathVariable("duraId") Long duraId){
		DurationEntity duration = durationService.getById(duraId);

        return R.ok().put("duration", duration);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody DurationEntity duration){
		durationService.save(duration);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody DurationEntity duration){
		durationService.updateById(duration);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] duraIds){
		durationService.removeByIds(Arrays.asList(duraIds));

        return R.ok();
    }

}
